﻿Public Class fConceptoPago
    Dim daConPago As lbGlobalcom.dsCarteraTableAdapters.CAR_CONCEPTOPAGOTableAdapter
    Dim daDatGlo As lbGlobalcom.dsGlobalTableAdapters.GLO_DATOSTABLASTableAdapter

    Private Sub fConceptoPago_FormClosing(ByVal sender As Object, ByVal e As System.Windows.Forms.FormClosingEventArgs) Handles Me.FormClosing
        If Me.DsCartera.CAR_CONCEPTOPAGO.GetChanges IsNot Nothing Then
            CAR_CONCEPTOPAGOBindingSource.EndEdit()
            If MessageBox.Show("Hay cambios pendientes por salvar, desea salvarlos", "Cambios pendientes", MessageBoxButtons.YesNo, MessageBoxIcon.Question) = Windows.Forms.DialogResult.Yes Then
                CAR_CONCEPTOPAGOBindingNavigatorSaveItem.PerformClick()
            End If
        End If
    End Sub

    Private Sub fConceptoPago_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
        Try
            daConPago = New lbGlobalcom.dsCarteraTableAdapters.CAR_CONCEPTOPAGOTableAdapter
            daDatGlo = New lbGlobalcom.dsGlobalTableAdapters.GLO_DATOSTABLASTableAdapter
            daDatGlo.FillByIdGrupo(DsGlobal.GLO_DATOSTABLAS, "td")
        Catch ex As Exception
            MessageBox.Show(ex.Message)
            lbGlobalcom.cError.SalvaError(ex, "Henry")
        End Try
    End Sub

    Private Sub btnCargar_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnCargar.Click
        Try
            If Me.DsCartera.CAR_CONCEPTOPAGO.GetChanges IsNot Nothing Then
                CAR_CONCEPTOPAGOBindingSource.EndEdit()
                If MessageBox.Show("Hay cambios pendientes por salvar, desea salvarlos", "Cambios pendientes", MessageBoxButtons.YesNo, MessageBoxIcon.Question) = Windows.Forms.DialogResult.Yes Then
                    CAR_CONCEPTOPAGOBindingNavigatorSaveItem.PerformClick()
                End If
            End If
            daConPago.Fill(DsCartera.CAR_CONCEPTOPAGO)
        Catch ex As Exception
            MessageBox.Show(ex.Message)
            lbGlobalcom.cError.SalvaError(ex, "Henry")
        End Try
    End Sub

    Private Sub CAR_CONCEPTOPAGOBindingNavigatorSaveItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CAR_CONCEPTOPAGOBindingNavigatorSaveItem.Click
        Try
            Validate()
            CAR_CONCEPTOPAGOBindingSource.EndEdit()
            daConPago.Update(DsCartera.CAR_CONCEPTOPAGO)
            MessageBox.Show("Se salvarón registros con exito", "Salvar Registro", MessageBoxButtons.OK, MessageBoxIcon.Information)
        Catch ex As Exception
            MessageBox.Show(ex.Message)
            lbGlobalcom.cError.SalvaError(ex, "Henry")
        End Try
    End Sub

    Private Sub BindingNavigatorDeleteItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BindingNavigatorDeleteItem.Click
        Try
            If MessageBox.Show("Esta seguro que desea eliminar este registro", "Elimina Registro", MessageBoxButtons.YesNo, MessageBoxIcon.Question) = Windows.Forms.DialogResult.Yes Then
                CAR_CONCEPTOPAGOBindingSource.RemoveCurrent()
                daConPago.Update(DsCartera.CAR_CONCEPTOPAGO)
            End If
        Catch ex As Exception
            MessageBox.Show(ex.Message)
            lbGlobalcom.cError.SalvaError(ex, "Henry")
        End Try
    End Sub

    Private Sub CAR_CONCEPTOPAGODataGridView_DataError(ByVal sender As Object, ByVal e As System.Windows.Forms.DataGridViewDataErrorEventArgs)
        MessageBox.Show(e.Exception.Message)
    End Sub

    Private Sub CAR_CONCEPTOPAGODataGridView_UserDeletedRow(ByVal sender As Object, ByVal e As System.Windows.Forms.DataGridViewRowEventArgs)
        Try
            daConPago.Update(DsCartera.CAR_CONCEPTOPAGO)
        Catch ex As Exception
            MessageBox.Show(ex.Message)
            lbGlobalcom.cError.SalvaError(ex, "Henry")
        End Try
    End Sub

    Private Sub CAR_CONCEPTOPAGODataGridView_UserDeletingRow(ByVal sender As Object, ByVal e As System.Windows.Forms.DataGridViewRowCancelEventArgs)
        Try
            If MessageBox.Show("Esta seguro que desea eliminar este registro", "Elimina Registro", MessageBoxButtons.YesNo, MessageBoxIcon.Question) = Windows.Forms.DialogResult.No Then
                e.Cancel = True
            End If
        Catch ex As Exception
            MessageBox.Show(ex.Message)
            lbGlobalcom.cError.SalvaError(ex, "Henry")
        End Try
    End Sub

End Class